package com.xyy.saas.payment.payment.core.adapter;

import com.xyy.saas.payment.common.exception.PaymentException;
import com.xyy.saas.payment.cores.enums.*;
import com.xyy.saas.payment.cores.param.ProfitSharingParam;
import org.apache.commons.lang3.StringUtils;

public class CheckParamAdapter {
    public static void checkProfitSharingParam(ProfitSharingParam profitsharingParam) throws PaymentException {
        if(profitsharingParam == null) {
            throw new PaymentException(ResultCodeEnum.PARAM_SUBJECT_ERROR);
        }

        if(profitsharingParam.getBusinessType() == null) {
            throw new PaymentException("businessType|不能为空");
        }
        if(profitsharingParam.getBusinessOrderType() == null) {
            throw new PaymentException("businessOrderType|不能为空");
        }
        if(StringUtils.isBlank(profitsharingParam.getBusinessId())) {
            throw new PaymentException("businessId|不能为空");
        }
        if(profitsharingParam.getBusinessIdType() == null) {
            throw new PaymentException("businessIdType|不能为空");
        }
        if(StringUtils.isBlank(profitsharingParam.getCallback())) {
            throw new PaymentException("callback|不能为空");
        }
        if(profitsharingParam.getInvoker() == null) {
            throw new PaymentException("invoker|不能为空");
        }
        if(StringUtils.isBlank(profitsharingParam.getBusinessOrderNo())) {
            throw new PaymentException("businessOrderNo|不能为空");
        }
        if(StringUtils.isBlank(profitsharingParam.getBusinessName())) {
            throw new PaymentException("businessName|不能为空");
        }
        if(profitsharingParam.getTotalGoodsAmount() == null) {
            throw new PaymentException("totalGoodsAmount|不能为空");
        }
        if(profitsharingParam.getTotalFreightAmount() == null) {
            throw new PaymentException("totalFreightAmount|不能为空");
        }
        if(profitsharingParam.getTotalAmount() == null) {
            throw new PaymentException("totalAmount|不能为空");
        }
        if(profitsharingParam.getTotalStoreDiscountAmount() == null) {
            throw new PaymentException("totalStoreDiscountAmount|不能为空");
        }
        if(profitsharingParam.getTotalPlatformDiscountAmount() == null) {
            throw new PaymentException("totalPlatformDiscountAmount|不能为空");
        }
        if(profitsharingParam.getTotalPayAmount() == null) {
            throw new PaymentException("totalPayAmount|不能为空");
        }
        if(profitsharingParam.getTotalBalancePayAmount() == null) {
            throw new PaymentException("totalBalancePayAmount|不能为空");
        }
        if(profitsharingParam.getTotalOnlinePayAmount() == null) {
            throw new PaymentException("totalOnlinePayAmount|不能为空");
        }
        if(profitsharingParam.getTotalBrokerageAmount() == null) {
            throw new PaymentException("totalBrokerageAmount|不能为空");
        }
        if(profitsharingParam.getTotalSettleAmount() == null) {
            throw new PaymentException("totalSettleAmount|不能为空");
        }
        if(profitsharingParam.getDetails() == null) {
            throw new PaymentException("details|不能为空");
        }
    }
}
